<template>
    <user-card-list :user-list="userList" />
    <van-empty image="search" description="暂无数据" v-if="!userList || userList.length < 1" />
</template>

<script setup>
import { onMounted, ref } from 'vue'
import myAxios from '../plugins/myAxios.ts'
import UserCardList from '../components/UserCardList.vue'

const userList = ref([])

onMounted(async () => {
    const userPage = await myAxios.get('/user/recommend', {
        params: {
            currentPage: 1,
            pageSize: 8
        }
    })
        .then(resp => {
            console.log('请求成功', resp)
            return resp?.data
        })
        .catch(error => {
            console.log('请求失败', error)
        })

    if (userPage.records) {
        userPage.records.forEach(user => {
            if (user.tags) {
                user.tags = JSON.parse(user.tags)
            }
        })
        userList.value = userPage.records
    }
})

</script>

<style scoped>

</style>